package com.share.user.controller;

import com.share.common.core.context.SecurityContextHolder;
import com.share.common.core.domain.R;
import com.share.common.core.domain.Users;
import com.share.common.core.web.controller.BaseController;
import com.share.common.core.web.domain.AjaxResult;
import com.share.common.security.annotation.RequiresLogin;
import com.share.user.api.domain.UserInfo;
import com.share.user.api.domain.UserLogin;
import com.share.user.api.domain.UserVo;
import com.share.user.service.IUserInfoService;
import com.share.user.service.UserInfoService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

import static com.share.common.core.web.domain.AjaxResult.success;

@RestController
@RequestMapping("/userInfo")
public class UserInfoApiController extends BaseController {
    @Autowired
    private IUserInfoService userInfoService;




    @Operation(summary = "小程序授权登录")
//    @InnerAuth
    @GetMapping("/wxLogin/{code}")
    public R<UserInfo> wxLogin(@PathVariable String code) {

        return R.ok(userInfoService.wxLogin(code));
    }

    @Operation(summary = "更新用户登录信息")
//    @InnerAuth
    @PutMapping("/updateUserLogin")
    public R<Users> updateUserLogin(@RequestBody UserLogin userLogin)
    {
        userInfoService.updateUserLogin(userLogin);
        return R.ok();
    }
    @Operation(summary = "是否免押金")
    @RequiresLogin
    @GetMapping("/isFreeDeposit")
    public AjaxResult isFreeDeposit() {
        return success(userInfoService.isFreeDeposit());
    }
}
